package com.dhp.campus.Common;

import lombok.Data;

@Data
public class Result<T> {
    //定义响应数据
    private T data;
    private String message;
    private String description;
    private Integer code;

    /**
     * 全部信息
     * @param data
     * @param message
     * @param code
     */
    public Result(T data, String message, Integer code , String description) {
        this.data = data;
        this.message = message;
        this.code = code;
        this.description = description;
    }

    /**
     * 无message和description信息
     * @param data
     * @param code
     */
    public Result(T data , Integer code) {
        this(data , "" , code , "");
    }


    /**
     * 无message
     * @param data
     * @param code
     * @param description
     */
    public Result(T data , Integer code , String description) {
        this(data , "" , code , description);
    }


    /**
     * 自定义错误枚举类
     * @param errorCode
     */
    public Result(ErrorCode errorCode) {
        this(null , errorCode.getMessage() , errorCode.getCode() , errorCode.getDescription());
    }

    /**
     * 自定义code
     * @param code
     * @param message
     * @param description
     */
    public Result(Integer code , String message , String description){
        this(null , message , code , description);
    }

}
